export default{
	state:{
		token:'',
		userInfo:{},
		status: false
	},
	mutations:{
		initUser(state){
			let userInfo = uni.getStorageSync('xiaoluxian_userInfo')
			if(userInfo){
				userInfo = JSON.parse(userInfo)
				state.userInfo = userInfo
				state.status = true
				let token = uni.getStorageSync('xiaoluxian_token')
				if(token){
					state.token = token
				}
			}
			// console.log('initUser-->',userInfo)
		},
		setToken(state,token){
			state.token = token
			// uni.setStorageSync('xiaoluxian_token',JSON.stringify(token))
			uni.setStorageSync('xiaoluxian_token',token)
		},
		setUserInfo(state,userInfo){
			state.userInfo = userInfo
			state.status = true
			uni.setStorageSync('xiaoluxian_userInfo',JSON.stringify(userInfo))
		},
		clearUser(state){
			state.token = ''
			state.status = false
			state.userInfo = {}
			uni.removeStorageSync('xiaoluxian_token');
			uni.removeStorageSync('xiaoluxian_userInfo');
		}
	}
}